package com.jml.consumer;

import com.jml.service.DistributeService;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.ConsumeMode;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
@RocketMQMessageListener(consumerGroup = "spring_boot_consumer_group", topic = "jml-topic2022", consumeMode = ConsumeMode.CONCURRENTLY
)
public class RocketMQConsumer implements RocketMQListener<String> {
    @Autowired
    private DistributeService distributeService;

    @Override
    public void onMessage(String orderId) {
        log.info("消费者监听到消息：<orderId:{}>", orderId);
        distributeService.distributeOrder(orderId);
    }
}